
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">申请老师:</label>
        <div class="col-xs-12 col-sm-8">
            <input style="width: 80%" type="text" id="apply_nickname" class="form-control" readonly>
            <input type="hidden" name="row[admin_id]" id="apply_admin_id">
            <a href="javascript:;" data-multiple="false" data-area='["80%", "80%"]' class="btn btn-info apply_select">请选择老师</a>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">被代老师:</label>
        <div class="col-xs-12 col-sm-8">
            <input style="width: 80%" type="text" id="nickname" class="form-control" readonly>
            <input type="hidden" name="row[substitute_admin_id]" id="admin_id">
            <a href="javascript:;" data-multiple="false" data-area='["80%", "80%"]' class="btn btn-info select">请选择老师</a>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('公假代')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select class="form-control" name="row[public_leave]">
                <option value="0">否</option>
                <option value="1">是</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">选择时间:</label>
        <div class="col-xs-12 col-sm-8">
            <input style="width: 85%" id="c-select_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" type="text" value="{:date('Y-m-d')}">
            <button type="button" onclick="add_time()" class="btn">添加</button>

        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Select_time')}:</label>
        <div class="col-xs-12 col-sm-8" id="time_div">

        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Num')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-num" class="form-control" data-rule="required" name="row[num]" type="number" value="0">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Remarks')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-remarks" class="form-control" data-rule="required" name="row[remarks]" type="text" value="">
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
<script>
    var num = 0;
    function add_time(){
        var select_time = $('#c-select_time').val();
        if(!select_time){
            layer.msg('请选择时间');
            return;
        }
        var html = '<div style="margin-top: 10px;" id="time_div_'+num+'"><input readonly style="width: 85%" class="form-control" name="row[times][]" value="'+select_time+'">\n' +
            ' <button type="button" style="display: red" onclick="del_time('+num+')" class="btn">删除</button></div>';
        $('#c-select_time').val('');
        $('#time_div').append(html);
    }

    function del_time(id){
        $('#time_div_'+id).remove();
    }
</script>